package com.ty.day3;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : txy
 * @Create 2023/10/30 15:12
 */
public class Seven {
    public static void main(String[] args) {
        int a = 8;
        for (int i = 0; i < 5; i++) {
            a += 2;
            System.out.println("第" + (i + 1) + "个人 " + a + "岁");
        }
        System.out.println("所以第5个人" + a + "岁");
        System.out.println("\n递归：\n第5个人" + func(5) + "岁");
    }

    private static int func(int i) {
        if (i == 1) {
            return 10;
        } else {
            return func(i - 1) + 2;
        }
    }
}
